package com.yunsom.testdemo.design.adapter;

/**
 * @author Xbao
 * @description
 * @date 2022/6/20 14:00
 */
public class AudioPlayer implements MediaPlayer{

  MediaAdapter mediaAdapter;

  @Override
  public void play(String audioType, String fileName) {

    // 内置了avi的播放支持
    if("avi".equalsIgnoreCase(audioType)){
      System.out.println("Playing avi, fileName: "+ fileName);
    }
    // mediaPlayer支持了其他模式的播放支持
    else if("mp3".equalsIgnoreCase(audioType) || "mp4".equalsIgnoreCase(audioType)){
      mediaAdapter = new MediaAdapter(audioType);
      mediaAdapter.play(audioType, fileName);
    }
    else {
      System.out.println("unsupported media type:" + audioType);
    }

  }
}
